-- @owner: @zhanghuan96
-- @date: 2024/11/5
-- @testpoint: GMS_XMLGEN.GETXMLTYPE语法1，传入句柄不存在，合理报错
@conn PrimaryDbAmode;
--前置条件
drop extension if exists gms_xmlgen;
create extension gms_xmlgen;
set behavior_compat_options = 'bind_procedure_searchpath';
--step1:建表
drop table if exists t_getxmltype0003;
create table t_getxmltype0003 ("integer" integer);
insert into t_getxmltype0003 values(1);

--step2:句柄id关闭，使用getxmltype查询，报错
DECLARE
xml_cxt gms_xmlgen.ctxhandle;
xml_type xmltype;
BEGIN
xml_cxt := gms_xmlgen.newcontext('select * from t_getxmltype0003');
gms_xmlgen.closecontext(xml_cxt);
xml_type := gms_xmlgen.getxmltype(xml_cxt);
END;
/
--step3:句柄id未初始化，使用getxmltype查询，报错
DECLARE
xml_cxt gms_xmlgen.ctxhandle;
xml_type xmltype;
BEGIN
xml_cxt := gms_xmlgen.newcontext('select * from t_getxmltype0003');
xml_type := gms_xmlgen.getxmltype(xml_cxt1);
RAISE INFO 'INFO:XML Output: %', xml_type::text;
gms_xmlgen.closecontext(xml_cxt);
END;
/

--step4:清理环境;expect:成功
drop table if exists t_getxmltype0003;
drop extension if exists gms_xmlgen;